<template>
	<el-form  :model="patientform" label-width="80px">
	
		<el-form-item label="病人号">
			<el-input v-model="patientform.patientId"></el-input>
		</el-form-item>
		<el-form-item label="姓名">
			<el-input v-model="patientform.name"></el-input>
		</el-form-item>
		<el-form-item label="性别">
			<el-input v-model="patientform.sex"></el-input>
		</el-form-item>
		<el-form-item label="年龄">
			<el-input v-model="patientform.age"></el-input>
		</el-form-item>
		<el-form-item label="身份证">
			<el-input v-model="patientform.idcard"></el-input>
		</el-form-item>
		<el-form-item label="出生日期">
			<el-date-picker
						      v-model="patientform.birthday"
						      type="date"
							  value-format="yyyy-MM-dd"
						      placeholder="选择日期">
						    </el-date-picker>
		</el-form-item>
		<el-form-item label="主治医生">
			<el-input v-model="patientform.contact"></el-input>
		</el-form-item>
		<el-form-item label="手机号">
			<el-input v-model="patientform.telphone"></el-input>
		</el-form-item>
		<el-form-item label="治疗周期">
			<el-input v-model="patientform.address"></el-input>
		</el-form-item>
		<el-form-item label="病房号">
			<el-input v-model="patientform.room"></el-input>
		</el-form-item>
		<el-form-item label="所属楼房">
			<el-input v-model="patientform.building"></el-input>
		</el-form-item>
		<el-form-item label="入住时间">
			<el-date-picker
						      v-model="patientform.indate"
						      type="date"
							  value-format="yyyy-MM-dd"
						      placeholder="选择日期">
						    </el-date-picker>
		</el-form-item>
		<el-form-item label="搬出时间">
			<el-date-picker
						      v-model="patientform.outdate"
						      type="date"
							  value-format="yyyy-MM-dd"
						      placeholder="选择日期">
						    </el-date-picker>
		</el-form-item>
		<el-form-item label="备注">
			<el-input v-model="patientform.remark"></el-input>
		</el-form-item>
		<el-form-item label="护士">
			<el-input v-model="patientform.nursingId"></el-input>
		</el-form-item>
		
		<el-button type="primary" @click="doPatientEdit">提交</el-button>
	</el-form>
</template>

<script>
	
	export default{
		name:'PatientEdit',
		props:{			
			formData:{
				type:Object,
				default:()=>({})
			},
			editVisible:{
				type:Boolean,
			}
		},
		data(){
			return {
				patientform:{
					patientId:'',
					name:'',
					sex:'',
					age:'',
					idcard:'',
					birthday:'',
					contact:'',
					telphone:'',
					address:'',
					room:'',
					building:'',
					indate:'',
					outdate:'',
					remark:'',
					nursingId:''
																		}
			}
		},
		mounted(){
					this.patientform=this.formData;
					console.log("子组件数据:");
					console.log(this.patientform)
				},
				methods:{
					doPatientEdit(){
						this.postRequest("/patient/update",this.patientform).then(resp=>{
							if(resp){
								this.$emit("update:editVisible",false);
							}else{
								this.$message.error({message:'编辑失败'});
							}
						})
					}
				},
				watch:{
					formData:{
						deep:true,
						handler(newVal,oldVal){
							this.patientform=newVal
						}
					}
				}
	}
</script>

<style>
</style>
